﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ExportToPLMX.SimulationStateExporter.CApExportToPlmxObjectsFrameData
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;


namespace DnProcessSimulateCommands.ExportToPLMX.SimulationStateExporter;

[DataContract]
internal class CApExportToPlmxObjectsFrameData
{
  [DataMember(Order = 0)]
  public double time;
  [DataMember(EmitDefaultValue = false, Order = 1)]
  public CApExportToPlmxCameraStateData camera;
  [DataMember(Order = 2)]
  public List<CApExportToPlmxObjectStateData> objStates = new List<CApExportToPlmxObjectStateData>();

  private static int CompareObjectStateData(
    CApExportToPlmxObjectStateData x,
    CApExportToPlmxObjectStateData y)
  {
    int num = 0;
    if (x == null)
    {
      if (y != null)
        num = -1;
    }
    else
      num = y != null ? x.i.CompareTo(y.i) : 1;
    return num;
  }

  internal void SortObjectStates()
  {
    this.objStates.Sort(new Comparison<CApExportToPlmxObjectStateData>(CApExportToPlmxObjectsFrameData.CompareObjectStateData));
  }

  internal bool Equals(object other, List<string> idList, List<string> otherIdList)
  {
    CApExportToPlmxObjectsFrameData objectsFrameData = other as CApExportToPlmxObjectsFrameData;
    bool flag = (!TxDoubleExtension.AlmostEquals(this.time, objectsFrameData.time) || this.camera != null ? this.camera.Equals((object) objectsFrameData.camera) : objectsFrameData.camera == null) && this.objStates.Count.Equals(objectsFrameData.objStates.Count);
    for (int index = 0; index < this.objStates.Count & flag; ++index)
    {
      string id = idList[this.objStates[index].i - 1];
      int otherIndex = otherIdList.FindIndex((Predicate<string>) (x => x == id));
      flag = this.objStates[index].Equals((object) objectsFrameData.objStates.Find((Predicate<CApExportToPlmxObjectStateData>) (x => x.i == otherIndex + 1)));
    }
    return flag;
  }
}
